﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Globalization;



namespace Projet
{
    /// <summary>
    /// Interaction logic for CreatePlanning.xaml
    /// </summary>
    public partial class CreatePlanning : Window
    {
        Bdd bdd = new Bdd();
        
        public CreatePlanning()
        {
            InitializeComponent();
            CultureInfo myCI = new CultureInfo("en-US");
            Calendar myCal = myCI.Calendar;
            int curweek = myCal.GetWeekOfYear(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day), CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
            manageLabelCursus.ItemsSource = bdd.getCursus();
            CampusBox.ItemsSource = bdd.GetCampus();
            currentWeek.Content = curweek.ToString();
            chooseWeek.SelectedIndex = curweek;
            chooseYear.SelectedIndex = DateTime.Now.Year - 2010;
        }

        private void addThis_Click(object sender, RoutedEventArgs e)
        {
            try { 
                bdd.CreatePlanning(manageLabelCursus.SelectedItem.ToString(), CampusBox.SelectedItem.ToString(), manageLabelClasses.SelectedIndex, chooseWeek.SelectedIndex, DateTime.Now.Year + chooseYear.SelectedIndex);
               // timeTableGridAdmin.ItemsSource = bdd.getPlanning(CampusBox.SelectedItem.ToString(), manageLabelCursus.SelectedItem.ToString(), chooseWeek.SelectedIndex, manageLabelClasses.SelectedIndex, DateTime.Now.Year + chooseYear.SelectedIndex);
                this.Close();
            }
            catch { MessageBox.Show("Missing parameters. Choose a campus and a Cursus"); }
           
        }

      
    }
}
